﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace HTSwitchServerNamespace.Util
{
    class TimerClass
    {

         private int invokeCount;
        private int  maxCount;

        /// <summary>
        /// STATUS CHECKER
        /// </summary>
        /// <param name="count"></param>
        public TimerClass(int count) //STATUS CHECKER
        {
            invokeCount  = 0;
            maxCount = count;
        }

        // This method is called by the timer delegate. 
        public void CheckStatus(Object stateInfo)
        {
            AutoResetEvent autoEvent = (AutoResetEvent)stateInfo;
            //Console.WriteLine("{0} Checking status {1,2}.", DateTime.Now.ToString("h:mm:ss.fff"), (++invokeCount).ToString());
            ++invokeCount;

            if(invokeCount == maxCount)
            {
                // Reset the counter and signal Main.
                invokeCount  = 0;
                autoEvent.Set();
            }
        }
    }
    
}
